package com.backstage.web;

import com.backstage.pojo.dto.Message;
import com.backstage.pojo.vo.SysPermissionVo;
import com.backstage.service.SysPermissionService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SysPermissionController {
    @Autowired
    SysPermissionService syspermissionService;

    @RequestMapping(value = "/permission", method = RequestMethod.GET)
    public Message<List<SysPermissionVo>> findList(SysPermissionVo sysPermissionVo) {
        return syspermissionService.list(sysPermissionVo);
    }

    @RequestMapping(value = "/permissions", method = RequestMethod.GET)
    public Message<SysPermissionVo> get(Long id) {
        return syspermissionService.get(id);
    }

    @RequestMapping(value = "/permissions/permission", method = RequestMethod.PUT)
    public Message<SysPermissionVo> add(SysPermissionVo sysPermissionVo) {
        return syspermissionService.add(sysPermissionVo);
    }

    @RequestMapping(value = "/permissions/permission", method = RequestMethod.POST)
    public Message<SysPermissionVo> update(SysPermissionVo sysPermissionVo) {
        return syspermissionService.edit(sysPermissionVo);
    }

    @RequestMapping(value = "/permissions/permission/{id}", method = RequestMethod.DELETE)
    public Message<SysPermissionVo> delete(@PathVariable int id) {
        return syspermissionService.delete(id);
    }
}
